package com.wanmait.recruitment.webController;

import com.wanmait.recruitment.pojo.Industry;
import com.wanmait.recruitment.service.ConfigService;
import com.wanmait.recruitment.service.IndustryService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("zhuang/industry")
public class IndustryController {
    @Resource
    private IndustryService industryService;
    @Resource
    private ConfigService configService;

    @RequestMapping("list")
    public ModelAndView list(){
        ModelAndView modelAndView = new ModelAndView();
        List<Industry> industrys = industryService.findAll();
        modelAndView.addObject("industrys",industrys);
        Integer count = 0;
        try {
            count = Integer.parseInt(configService.getValueByKey("web_siderTop_count"));
        } catch (NumberFormatException e) {
            count = Integer.parseInt(configService.getDefaultValueByKey("web_siderTop_count"));
        }
        modelAndView.addObject("count",count);
        modelAndView.addObject("defaultCount",count);
        return modelAndView;
    }
}
